<template>
	<view :class="[BackGround]" :style="[{'font-weight':Style,'font-family':Font,height:100 + '%',minHeight:height + 'px'}]">
		<cu-custom bgColor="bg-gradual-blue" isBack="true">
			<view slot="backText">返回</view>
			<view slot="content">修改合格单录入详情</view>
		</cu-custom>
		<view :class="['margin-xs radius shadow shadow-lg bg-white' ,BackGroundBox]" v-if="isShow">
			<form @submit="formSubmit" @reset="formReset">
				<view class="cu-form-group">
					<view class="title">原料名称</view>
					<input type="text" name="LYLNAME" :value="item.LYLNAME" placeholder="请输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">原料编号</view>
					<input type="text" name="LYLCODE" :value="item.LYLCODE" placeholder="请输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">色号</view>
					<input type="text" name="LLCOLORCODE" :value="item.LLCOLORCODE" placeholder="请输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">颜色</view>
					<input type="text" name="LLCOLORNAME" :value="item.LLCOLORNAME" placeholder="请输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">数量</view>
					<input type="number" name="LLWEIGHT" :value="item.LLWEIGHT" placeholder="请输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">明细备注</view>
					<input type="text" name="LTSREMARK" :value="item.LTSREMARK" placeholder="请输入" />
				</view>
				<button-father :Position="'tb-fa-fixed'">
					<button class="cu-btn bg-gradual-blue lg shadow tb-flex cu-btn-new" form-type="submit">确认</button>
				</button-father>
			</form>
		</view>
	</view>
</template>

<script>
	import ButtonFather from '@/colorui/components/ButtonFather.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	import {
		getselectReferList
	} from "@/service/selectList"
	export default {
		data() {
			return {
				isShow: true,
				height:this.screenHeight,
				item:{},
				index:''
			}
		},
		computed: {
			...mapGetters(['Style', 'Font', 'Certificateofconformitygetitem','BackGround','BackGroundBox'])
		},
		components: {
			ButtonFather
		},
		onLoad(options) {
			console.log(options.item);
			this.item = JSON.parse(options.item)
			this.index = options.index
		},
		methods: {
			...mapMutations(['Certificateofconformitysetlist','Certificateofconformitydellist']),
			formSubmit(e) {
				console.log(e.detail.value);
				//定义表单规则
				var rule = [{
					name: "LYLNAME",
					checkType: "notnull",
					errorMsg: "请输入原料名称"
				},{
					name: "LYLCODE",
					checkType: "notnull",
					errorMsg: "请输入原料编号"
				},{
					name: "LLCOLORCODE",
					checkType: "notnull",
					errorMsg: "请输入色号"
				}, {
					name: "LLCOLORNAME",
					checkType: "notnull",
					errorMsg: "请输入颜色"
				},{
					name: "LLWEIGHT",
					checkType: "notnull",
					errorMsg: "请输入数量"
				},{
					name: "LTSREMARK",
					checkType: "notnull",
					errorMsg: "请输入备注"
				},];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = this.$graceChecker.check(formData, rule);
				if (!checkRes) {
					uni.showToast({
						title: this.$graceChecker.error,
						icon: "none"
					});
				} else {
					this.Certificateofconformitydellist(this.index)
					this.Certificateofconformitysetlist(e.detail.value)
					uni.navigateBack({
						delta: 1
					})
					uni.showToast({
						title: '添加成功',
						icon: 'success',
						duration: 3000
					});
				}
			},
			formReset(e) {}
		}
	}
</script>

<style>
	page {
		background-color: whitesmoke;
	}
</style>
